package com.yeung.exam;

import java.util.Scanner;

/**
 * fixprefixsuffix
 */
public class 字符串以相同前缀和后缀 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        int len = line.length();
        String result="Just a legend";
        for (int i = 1; i < line.length(); i++) {
            String pre=line.substring(0,i);
            if (line.endsWith(pre)&&line.substring(1).contains(pre)) {
                result = pre;
                break;
            }
        }
        System.out.println(result);

    }
}
